<template>
	<view class="content">
		<!-- 空白页 -->
		<!-- <view class="zwtimg placeholderimg flexcenter" style="margin-top: 300rpx;" v-if="recordList.data.length==0">
			<image src="@/static/image/bg-icons/placeholderimg.png" mode=""></image>
		</view> -->
		<view class="padding_lrb ffffff margin_top">
			<!-- <view class="flexbetween margin_bottom5">
				<view class="color_ling text_a">
					合计：<text style="color: rgba(243, 39, 28, 1);">￥{{total_price}}</text>
				</view>
			</view> -->
			<view class="line padding_bottom" v-for="(item,index) in recordList.data" :key="item.id">
				<view class="margin_top flexbetween">
					<view class="reds">{{item.withdraw_price}}</view>
					<view class="status" v-if="item.state==1">待审核</view>
					<view class="status" v-if="item.state==2">已完成</view>
					<view class="status" v-if="item.state==3">已驳回</view>
					<view class="status suergetprice" @click="sureGetPrice(item)" v-if="item.state==4">
						<view class="suergetpriceBtn">
							确认收款
						</view>
					</view>
				</view>
				<view class="time margin_top2">{{date(item.createtime)}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	// #ifdef APP-PLUS
	import {requestMerchantTransfer} from "@/uni_modules/uni-requestMerchantTransfer"
	// #endif
	export default {
		data() {
			return {
				page: 1,
				recordList: {
					data: []
				},
				// total_price:0,//合计价格
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			sureGetPrice(data){
				requestMerchantTransfer({
				    "mchId": "1649975289",
				    "appId": "wxfb83ed84a0c57c8e",
				    "package": data.package_info,
				    success: (res) => {
				        console.log(res)
				    },
				    fail: (res) => {
				        console.log(res.errMsg)
				    },
				    complete: (res) => {
				        console.log(res.errMsg)
				    }
				})
				
			},
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/shop.index/withdraw_log', 'GET', {
					page: page || 1,
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.recordList;
						if (isPage == true) {
							_this.recordList.data = dataList.data.concat(resList.data);
						} else {
							_this.recordList = res.data
							_this.recordList.data = resList.data;
						}
						// _this.recordList.data.forEach(item=>{
						// 	_this.total_price+=Number(item.withdraw_price)
						// })
					} else if (res.code == 0) {
						httpRequest.toast(res.msg);
					} else {
						httpRequest.toast('网络开小差啦');
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.recordList;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style>
	.content {
		overflow: hidden;
	}
	
	.suergetprice{
		padding: 10rpx;
		box-sizing: border-box;
	}
	
	.suergetpriceBtn{
		background-color: rgba(243, 39, 28, 1);
		border-radius: 41rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		font-family: PingFang SC-Medium, PingFang SC;
		color: #FFFFFF;
		height: 50rpx;
		width: 150rpx;
	}

	.status {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.reds {
		font-size: 32rpx;
		font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
		font-weight: bold;
		color: rgba(243, 39, 28, 1);
	}

	.time {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}
</style>